package kr.co.doriclassic.chapter22;

import java.util.HashMap;
import java.util.Map;



public class MapTest {
	public static void main(String[] args) {
		Map<Integer, Student> map = new HashMap<>();

		map.put(1, new Student(1, "김태희", 100, 90, 50));
		map.put(2, new Student(2, "이나영", 40, 90, 50));
		map.put(3, new Student(3, "태연", 80, 90, 50));
		
		map.remove(1);
		
		System.out.println(map);
		
		for (Map.Entry<Integer, Student> s : map.entrySet()) {
			int key = s.getKey();
			Student value = s.getValue();
			
			System.out.println("key:"+key+"value:"+value);
		}
	
		Map<String, Integer> m = new HashMap<>();
		String[] sample = {"to", "be", "or", "not", "to", "be", "is", "a", "problem"};	
		for (String str : sample) {
			Integer freq = m.get(str);
			m.put(str, (freq==null)?1:freq+1);
		}
		
		System.out.println(m.size());
		System.out.println(m.containsKey("be"));
		System.out.println(m.isEmpty());
		System.out.println(m);
	}	
}
